<?php

include '../../init.php';

if (!$_SESSION['is_login'] || empty($_SESSION['uid'])) {
	show_msg(1, '请先登录', $time = 3, $url = '../../index.php');
	exit();
}

// 获取安全问题列表
$qarray = array();
$sql   = "SELECT qid,question FROM `safe_question_tb` ;";
if (!my_mysql_query($sql, $qarray)){
    echo '数据初始化失败';
    exit();
}


// 查询个人信息
$uid = $_SESSION['uid'];
$sql = "SELECT l.password,u.email,u.qid,u.answer FROM login_tb as l,userinfo_tb as u WHERE l.uid = u.uid AND l.uid=".$uid." LIMIT 1 ;";
$arr = array();
if (!my_mysql_query($sql, $arr)){
	show_msg(1, '获取个人信息失败', 3, '../../index.php');
	exit();
}
setSessionForKey($arr[0]);
?>
<!DOCTYPE html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>个人信息</title>
	<meta name="keywords" content="">

	<link rel="stylesheet" type="text/css" href="./css/style_3_common.css">
	<link rel="stylesheet" type="text/css" href="./css/style_3_home_space.css">
	<link rel="stylesheet" id="css_widthauto" type="text/css" href="./css/style_3_widthauto.css">
	<link rel="stylesheet" type="text/css" id="gfan_css" href="./css/gfan_bbs.css">

	<style type="text/css">
	.ct2_a .appl {
		margin-left: -150px;
	}
	.appl {
		float: left;
		overflow: hidden;
		margin-bottom: 10px;
		padding: 6px 10px;
		width: 117px;
	}
    .main-div{
        margin: 25px auto;
        width: 960px;
        background-color:#F7F7F7;
    }
    body{
        background-color:#F9F9F9;
    }
	</style>
</head>

<body id="nv_home" class="pg_space">
	<div id="wp" class="main-div">
		<div id="pt" class="bm cl">
			<div class="z">
				<a href="../../index.php" title="首页">首页</a> <em>›</em>个人资料
			</div>
		</div>
		<div id="ct" class="ct2_a wp cl">
			<div class="mn">
				<div class="bm bw0">
					<h1 class="mt">个人资料
					</h1>
					<ul class="tb cl">
						<li class="a"><a href="#">基本资料</a></li>
					</ul>
					<form action="update.php" method="post" autocomplete="off">
						<input type="hidden" name="method" value="update_safe_info">
						<table cellspacing="0" cellpadding="0" class="tfm" id="profilelist">
							<tbody>
								<tr>
									<th>旧密码</th>
									<td>
										<input type="password" name="oldpass" class="px" value="">
									</td>
									<td>&nbsp;</td>
								</tr>
								<tr id="tr_gender">
									<th>新密码</th>
									<td>
										<input type="password" name="newpass" class="px" value="">
									</td>
									<td>&nbsp;</td>
								</tr>
								<tr id="tr_birthday">
									<th>邮箱</th>
									<td>
										<input type="email" name="email" class="px" value="<?php echo $_SESSION['email']?>">
									</td>
									<td>&nbsp;</td>
								</tr>
								<tr id="tr_realname">
									<th>安全提问:</th>
									<td>
										<select id="loginquestionid_Lyel8" width="213" name="qid"><?php 
                                                            foreach($qarray as $value){
                                                                echo '<option value="'.$value['qid'].'">'.$value['question'].'</option>';
                                                            }
                                                            ?>
										</select>
									</td>
									<td>&nbsp;</td>
								</tr>
								<tr id="tr_residecity">
									<th>答案</th>
									<td>
										<input type="text" name="answer" class="px" value="<?php echo $_SESSION['answer']?>">
									</td>
									<td>&nbsp;</td>
								</tr>
								<tr>
									<th>&nbsp;</th>
									<td colspan="2">
										<input type="hidden" name="profilesubmit" value="true">
										<button type="submit" name="profilesubmitbtn" id="profilesubmitbtn" value="true" class="pn pnc">
											<strong>保存</strong>
										</button>
									</td>
									<td>&nbsp;</td>
								</tr>
							</tbody>
						</table>
					</form>
				</div>
			</div>
			<div class="appl">
				<div class="tbn">
					<h2 class="mt bbda">设置</h2>
					<ul>
						<li><a href="index.php?uid=<?php echo $uid;?>">个人资料</a></li>
						<li><a href="avatar.php">修改头像</a></li>
						<li class="a"><a href="#">密码安全</a></li>
						<li><a href="score.php">积分</a></li>
					</ul>
				</div>
			</div>
		</div>
	</div>
</body>
</html>
